<?php

namespace Admin\Controller;


/**
 * 前台管理员控制器
 * 主要获取管理员页聚合数据
 */
class AdministratorController extends AdminController {
    
	//管理员管理
	public function administrator_management(){
        $map = array();
        $map  = array('status' => 1);//状态status的值
        if(isset($_GET['name'])){
            $map['name']    =   array('like', '%'.(string)I('name').'%');
        }
		$public_info = $this->lists('Admin_info',$map,'id asc');
		
	
		$lists = $this->lists('Admin_info',$map,'id asc');
		//$lists  = D('Customer_info')->where($map)->order('uid asc')->select();//查询语句
    	$this->assign('administratormanagement',$lists);
		$this->assign('publicinfo',$public_info);
	 
	    $this->display();
	}

	//管理员信息录入
	 public function admin_land($nature='',$name='',$address='',$phone='',$headname='',$headtellphone='',$email='',$position='',$qq='',$faxnumber='',$introduction=''){
		if($_POST['submit']!=""){
			$admin_info=array('nature'=>$nature,'name'=>$name,'address'=>$address,'phone'=>$phone,'headname'=>$headname,'headtellphone'=>$headtellphone,'email'=>$email,'position'=>$position,'qq'=>$qq,'faxnumber'=>$faxnumber,'introduction'=>$introduction);
			if(!M('Admin_info')->add($admin_info)){
				//$this->error('信息录入失败！', U('Index/index'));
				echo "<script>alert('信息录入失败！');</script>";
			}else{
				//$this->success('信息录入成功！');
				echo "<script>alert('信息录入成功！');</script>";
			}

		}
		
		
		$this->display();
	 
	 }
	 //管理员区域划分
	 public function admin_region(){
	 

	   $this->display();
	 
	 }

	
	

	//删除操作
	public function del(){
		$id=array_unique((array)I('id',0));
		if(empty($id)){
			$this->error('请输入数据!');

		}
		$where=array('id'=>array('in',$id));
		if(M('Admin_info')->where($where)->delete()){
			S('DB_CONFIG_DATA',null);
			//记录行为
			action_log('update_config','Admin_info',$id,ID);
			$this->success('删除成功！');
		}else{
			$this->error('删除失败！');
		}
	}

}
